home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
wtj009.zip
/
CPP_DLL.ZIP
/
LISTINGS.TXT
< prev
next >
Wrap
Text File
|
1992-08-14
|
4KB
|
167 lines
============================================================================
[LISTING 1 - HELLO.CPP]
// hello.cpp RHS 7/15/92
#include<windows.h>
LPSTR wintitle = "HELLO";
LPSTR winmessage ="Hello, world!";
void FAR PASCAL HelloMessage(LPCSTR wintitle)
{
MessageBox(NULL,winmessage,wintitle,MB_OK);
}
int PASCAL WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
HelloMessage(wintitle);
return 0;
}
============================================================================
[LISTING 2 - HELLO2.CPP]
// hello2.cpp RHS 7/15/92
#include<windows.h>
#include"hello.h"
LPSTR wintitle = "HELLO2";
int PASCAL WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
HelloMessage(wintitle);
return 0;
}
============================================================================
[LISTING 3 - HELLOLIB.CPP]
// hellolib.cpp RHS 7/15/92
#include<windows.h>
#include"hello.h"
#if defined(_MSC_VER)
extern "C" int FAR PASCAL LibMain(HINSTANCE,WORD,WORD,LPSTR)
{
return TRUE;
}
extern "C" int FAR PASCAL _WEP(int)
{
return TRUE;
}
#else
int FAR PASCAL LibMain(HINSTANCE,WORD,WORD,LPSTR)
{
return TRUE;
}
int FAR PASCAL WEP(int)
{
return TRUE;
}
#endif
LPSTR winmessage = "Hello, world!";
void FAR PASCAL _export HelloMessage(LPSTR wintitle)
{
MessageBox(NULL,winmessage,wintitle,MB_OK);
}
============================================================================
[LISTING 4 - MAKE FILES]
#Borland C++ Make file:
all: hello.exe hellolib.dll hellolib.lib hello2.exe
hello.exe: hello.cpp
bcc -WS -DSTRICT hello.cpp
hellolib.dll: hellolib.def hellolib.cpp hello.h
bcc -WD -DSTRICT hellolib.cpp
hellolib.lib: hellolib.dll
implib hellolib.lib hellolib.dll
hello2.exe: hello2.cpp hellolib.lib hello.h
bcc -WS -DSTRICT hello2.cpp hellolib.lib
#Microsoft C++ 7.0 Make file:
all: hello.exe hellolib.dll hellolib.lib hello2.exe
hello.exe: hello.cpp
cl /GA /DSTRICT hello.cpp hello.def
hellolib.dll: hellolib.def hellolib.cpp hello.h
cl /c /GD /DSTRICT hellolib.cpp
link hellolib,hellolib.dll,null,libw sdllcew,hellolib.def;
hellolib.lib: hellolib.dll
implib hellolib.lib hellolib.dll
hello2.exe: hello2.cpp hellolib.lib hello.h
cl /c /GA /DSTRICT hello2.cpp
link hello2,hello2.exe,null,libw slibcew hellolib,hello2.def;
============================================================================
[LISTING 5 - MODULE DEFINITION (.DEF) FILES]
; HELLO.DEF
NAME HELLO
DESCRIPTION 'Hello'
STUB 'winstub.exe'
EXETYPE WINDOWS
HEAPSIZE 8192
STACKSIZE 8192
; HELLOLIB.DEF
LIBRARY HELLOLIB
DESCRIPTION 'Hello Library'
STUB 'winstub.exe'
EXETYPE WINDOWS
CODE MOVEABLE PRELOAD
DATA SINGLE MOVEABLE PRELOAD
HEAPSIZE 8192
; HELLO2.DEF
NAME HELLO2
DESCRIPTION 'Hello2'
STUB 'winstub.exe'
EXETYPE WINDOWS
HEAPSIZE 8192
STACKSIZE 8192
============================================================================
[LISTING 6 - HELLO.H]
// hello.h RHS 7/15/92
#if defined(_WINDLL) || (__DLL__)
#define EXPORT _export
#else
#define EXPORT
#endif
extern void FAR PASCAL EXPORT HelloMessage(LPSTR wintitle);
=====================================================================